package com.zhj.leetcode;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;

/**
 * 力扣 389 找不同
 */
public class Test389 {
    public static void main(String[] args) {
        String s1 = "aerds345d";
        String s2 = "aeerds";
        System.out.println(more(s1, s2));
    }
    private static String more(String s1, String s2) {
        String res = "";
        char[] chars1 = s1.toCharArray();
        char[] chars2 = s2.toCharArray();
        Map<Character,Integer> cache = new HashMap<>();
        for (char c : chars1) {
            if (cache.containsKey(c)) {
                cache.put(c, cache.get(c) + 1);
            } else {
                cache.put(c, 1);
            }
        }
        for (char c : chars2) {
            if (cache.containsKey(c)) {
                cache.put(c, cache.get(c) - 1);
            } else {
                cache.put(c, 1);
            }
        }
        for (Map.Entry<Character, Integer> entry : cache.entrySet()) {
            if (entry.getValue() != 0) {
                res = res + entry.getKey();
            }
        }
        return res;
    }
}
